package com.bdsy.business.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bdsy.business.dao.AppUpdateMapper;
import com.bdsy.business.model.AppUpdate;
import com.bdsy.business.service.AppUpdateService;
import com.bdsy.common.utils.DateUtil;

@Service
public class AppUpdateServiceImpl implements AppUpdateService {

	@Autowired
	AppUpdateMapper appVersionMapper;
	
	@Override
	public boolean uploadApp(AppUpdate appUpdate) {
		// 修改 其它为不更新
		appVersionMapper.updateApp();
		appUpdate.setAppTime(DateUtil.getCurrentDate());
		appUpdate.setIsUpdate(1);
		
		int result = appVersionMapper.uploadApp(appUpdate);
		return result>0?true:false;
	}

	@Override
	public boolean downloadApp(String appVersion) {
		int result = 0;
		return result>0?true:false;
	}

	@Override
	public List<AppUpdate> selectAppUpdateByVersion(String appVersion) {
		List<AppUpdate> appUpdate = appVersionMapper.selectAppUpdateByVersion(appVersion);
		return appUpdate;
	}

	@Override
	public AppUpdate selectAppUpdateByIsUpdate(int isUpdate) {
		AppUpdate appUpdate =  appVersionMapper.selectAppUpdateByIsUpdate(isUpdate);
		return appUpdate;
	}

}
